import 'dart:convert';

class GoodsListModel {
  List<GoodsModel>? list;

  GoodsListModel({this.list});

  factory GoodsListModel.fromRawJson(String str) =>
      GoodsListModel.fromJson(json.decode(str));

  String toRawJson() => json.encode(toJson());

  factory GoodsListModel.fromJson(Map<String, dynamic> json) => GoodsListModel(
    list: List<GoodsModel>.from(
      json["list"].map((x) => GoodsModel.fromJson(x)),
    ),
  );

  Map<String, dynamic> toJson() => {
    "list": List<dynamic>.from(list!.map((x) => x.toJson())),
  };
}

class GoodsModel {
  ///档位ID
  int? id;
  String? goodId;
  double? goodUsPrice;
  int? goodCoin;
  int? giftGoodCoin;
  int? goodType;
  String? name;
  String? desc;
  int? rate;

  GoodsModel({
    this.id,
    this.goodId,
    this.goodUsPrice,
    this.goodCoin,
    this.giftGoodCoin,
    this.goodType,
    this.name,
    this.desc,
    this.rate,
  });

  factory GoodsModel.fromRawJson(String str) =>
      GoodsModel.fromJson(json.decode(str));

  String toRawJson() => json.encode(toJson());

  factory GoodsModel.fromJson(Map<String, dynamic> json) => GoodsModel(
    id: json["id"],
    goodId: json["good_id"],
    goodUsPrice: json["good_us_price"].toDouble(),
    goodCoin: json["good_coin"],
    giftGoodCoin: json["gift_good_coin"],
    goodType: json["good_type"],
    name: json["name"],
    desc: json["desc"],
    rate: json["rate"],
  );

  Map<String, dynamic> toJson() => {
    "id": id,
    "good_id": goodId,
    "good_us_price": goodUsPrice,
    "good_coin": goodCoin,
    "gift_good_coin": giftGoodCoin,
    "good_type": goodType,
    "name": name,
    "desc": desc,
    "rate": rate,
  };
}
